home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Tcl_SetVar(3) Tcl Library Procedures 7.0
-
-
-
- _________________________________________________________________
-
- NAME
- Tcl_SetVar, Tcl_SetVar2, Tcl_GetVar, Tcl_GetVar2,
- Tcl_UnsetVar, Tcl_UnsetVar2 - manipulate Tcl variables
-
- SYNOPSIS
- #include <tcl.h>
-
- char *
- Tcl_SetVar(_i_n_t_e_r_p, _v_a_r_N_a_m_e, _n_e_w_V_a_l_u_e, _f_l_a_g_s)
-
- char *
- Tcl_SetVar2(_i_n_t_e_r_p, _n_a_m_e_1, _n_a_m_e_2, _n_e_w_V_a_l_u_e, _f_l_a_g_s)
-
- char *
- Tcl_GetVar(_i_n_t_e_r_p, _v_a_r_N_a_m_e, _f_l_a_g_s)
-
- char *
- Tcl_GetVar2(_i_n_t_e_r_p, _n_a_m_e_1, _n_a_m_e_2, _f_l_a_g_s)
-
- int
- Tcl_UnsetVar(_i_n_t_e_r_p, _v_a_r_N_a_m_e, _f_l_a_g_s)
-
- int
- Tcl_UnsetVar2(_i_n_t_e_r_p, _n_a_m_e_1, _n_a_m_e_2, _f_l_a_g_s)
-
- ARGUMENTS
- Tcl_Interp *_i_n_t_e_r_p (in) Interpreter containing
- variable.
-
- char *_v_a_r_N_a_m_e (in) Name of variable. May
- refer to a scalar vari-
- able or an element of an
- array variable.
-
- char *_n_e_w_V_a_l_u_e (in) New value for variable.
-
- int _f_l_a_g_s (in) OR-ed combination of bits
- providing additional
- information for opera-
- tion. See below for valid
- values.
-
- char *_n_a_m_e_1 (in) Name of scalar variable,
- or name of array variable
- if _n_a_m_e_2 is non-NULL.
-
- char *_n_a_m_e_2 (in) If non-NULL, gives name
- of element within array
- and _n_a_m_e_1 must refer to
- an array variable.
-
-
-
- Tcl 1
-
-
-
-
-
-
- Tcl_SetVar(3) Tcl Library Procedures 7.0
-
-
-
- _________________________________________________________________
-
-
- DESCRIPTION
- These procedures may be used to create, modify, read, and
- delete Tcl variables from C code. Tcl_SetVar and
- Tcl_SetVar2 will create a new variable or modify an existing
- one. Both of these procedures set the given variable to the
- value given by _n_e_w_V_a_l_u_e, and they return a pointer to a copy
- of the variable's new value, which is stored in Tcl's vari-
- able structure. Tcl keeps a private copy of the variable's
- value, so the caller may change _n_e_w_V_a_l_u_e after these pro-
- cedures return without affecting the value of the variable.
- If an error occurs in setting the variable (e.g. an array
- variable is referenced without giving an index into the
- array), then NULL is returned.
-
- The name of the variable may be specified in either of two
- ways. If Tcl_SetVar is called, the variable name is given
- as a single string, _v_a_r_N_a_m_e. If _v_a_r_N_a_m_e contains an open
- parenthesis and ends with a close parenthesis, then the
- value between the parentheses is treated as an index (which
- can have any string value) and the characters before the
- first open parenthesis are treated as the name of an array
- variable. If _v_a_r_N_a_m_e doesn't have parentheses as described
- above, then the entire string is treated as the name of a
- scalar variable. If Tcl_SetVar2 is called, then the array
- name and index have been separated by the caller into two
- separate strings, _n_a_m_e_1 and _n_a_m_e_2 respectively; if _n_a_m_e_2 is
- zero it means that a scalar variable is being referenced.
-
- The _f_l_a_g_s argument may be used to specify any of several
- options to the procedures. It consists of an OR-ed combina-
- tion of any of the following bits:
-
- TCL_GLOBAL_ONLY
- Under normal circumstances the procedures look up vari-
- ables at the current level of procedure call for
- _i_n_t_e_r_p, or at global level if there is no call active.
- However, if this bit is set in _f_l_a_g_s then the variable
- is looked up at global level even if there is a pro-
- cedure call active.
-
- TCL_LEAVE_ERR_MSG
- If an error is returned and this bit is set in _f_l_a_g_s,
- then an error message will be left in _i_n_t_e_r_p->_r_e_s_u_l_t.
- If this flag bit isn't set then no error message is
- left (_i_n_t_e_r_p->_r_e_s_u_l_t will not be modified).
-
- TCL_APPEND_VALUE
- If this bit is set then _n_e_w_V_a_l_u_e is appended to the
- current value, instead of replacing it. If the
-
-
-
- Tcl 2
-
-
-
-
-
-
- Tcl_SetVar(3) Tcl Library Procedures 7.0
-
-
-
- variable is currently undefined, then this bit is
- ignored.
-
- TCL_LIST_ELEMENT
- If this bit is set, then _n_e_w_V_a_l_u_e is converted to a
- valid Tcl list element before setting (or appending to)
- the variable. A separator space is appended before the
- new list element unless the list element is going to be |
- the first element in a list or sublist (i.e. the |
- variable's current value is empty, or contains the sin- |
- gle character ``{'', or ends in `` }'').
-
- Tcl_GetVar and Tcl_GetVar2 return the current value of a
- variable. The arguments to these procedures are treated in
- the same way as the arguments to Tcl_SetVar and Tcl_SetVar2.
- Under normal circumstances, the return value is a pointer to
- the variable's value (which is stored in Tcl's variable
- structure and will not change before the next call to
- Tcl_SetVar or Tcl_SetVar2). The only bits of _f_l_a_g_s that are
- used are TCL_GLOBAL_ONLY and TCL_LEAVE_ERR_MSG, both of
- which have the same meaning as for Tcl_SetVar. If an error
- occurs in reading the variable (e.g. the variable doesn't
- exist or an array element is specified for a scalar vari-
- able), then NULL is returned.
-
- Tcl_UnsetVar and Tcl_UnsetVar2 may be used to remove a vari-
- able, so that future calls to Tcl_GetVar or Tcl_GetVar2 for
- the variable will return an error. The arguments to these
- procedures are treated in the same way as the arguments to
- Tcl_GetVar and Tcl_GetVar2. If the variable is successfully |
- removed then TCL_OK is returned. If the variable cannot be |
- removed because it doesn't exist then TCL_ERROR is returned.
- If an array element is specified, the given element is
- removed but the array remains. If an array name is speci-
- fied without an index, then the entire array is removed.
-
-
- SEE ALSO
- Tcl_TraceVar
-
-
- KEYWORDS
- array, interpreter, scalar, set, unset, variable
-
-
-
-
-
-
-
-
-
-
-
-
- Tcl 3
-
-
-
-